
import 'package:flutter/material.dart';
import 'package:flutter_base_widget/list/custom_widget/custom_native_view.dart';
import 'package:flutter_base_widget/list/custom_widget/custom_slider.dart';
import 'package:flutter_base_widget/list/notifier/notifier_page.dart';
import 'package:flutter_base_widget/list/widgets/alert_page.dart';
import 'package:flutter_base_widget/list/widgets/animation_icon_screen.dart';
import 'package:flutter_base_widget/list/widgets/animation_list.dart';
import 'package:flutter_base_widget/list/widgets/animation_paint.dart';
import 'package:flutter_base_widget/list/widgets/animation_progress.dart';
import 'package:flutter_base_widget/list/widgets/backdrop_filter.dart';
import 'package:flutter_base_widget/list/widgets/bottom_sheet.dart';
import 'package:flutter_base_widget/list/widgets/call_android_ios.dart';
import 'package:flutter_base_widget/list/widgets/card_page.dart';
import 'package:flutter_base_widget/list/widgets/chip_page.dart';
import 'package:flutter_base_widget/list/widgets/DraggableScrollableSheet.dart';
import 'package:flutter_base_widget/list/widgets/dismissable_screen.dart';
import 'package:flutter_base_widget/list/widgets/draw_path.dart';
import 'package:flutter_base_widget/list/widgets/file_operations.dart';
import 'package:flutter_base_widget/list/widgets/layoutbuilder_screen.dart';
import 'package:flutter_base_widget/list/widgets/picker_page.dart';
import 'package:flutter_base_widget/list/widgets/reorderabllistview.dart';
import 'package:flutter_base_widget/list/widgets/sliverappbar_screen.dart';
import 'package:flutter_base_widget/list/widgets/stepper_page.dart';
import 'package:flutter_base_widget/list/widgets/streambuilder_screen.dart';
import 'package:flutter_base_widget/list/widgets/warp_screen.dart';
import 'package:flutter_base_widget/theme/theme_notifier.dart';
import 'package:page_transition/page_transition.dart';
import 'package:provider/provider.dart';
import '../list/widgets/clickcounter_page.dart';

class ListModel {
  final String title;
  final String detail;
  final Widget jump;

  const ListModel(this.title, this.detail, this.jump);
}

class ListPage extends StatefulWidget {

  @override
  _ListPageState createState() => _ListPageState();
}

class _ListPageState extends State<ListPage> {


  final _datasource = [
    ListModel("Clip","它可以将一个复杂内容实体展现在一个小块中，如联系人",ChipPage()),
    ListModel("SimpleDialog","简单对话框可以显示附加的提示或操作",AlertPage()),
    ListModel("Card","一个 Material Design 卡片。拥有一个圆角和阴影",CardPage()),
    ListModel("AnimationList","一个滚动的容器，用于在插入或删除项目时对其进行动画处理。",AnimationListPage()),
    ListModel("ClickCounter","一个滚动的容器，用于在插入或删除项目时对其进行动画处理。",ClickCounter()),
    ListModel("BackdropFilterPage","BackdropFilter 滤镜：毛玻璃",BackdropFilterPage()),
    ListModel("CustomPainter","水波纹动画",CircleWaveRoute()),
    ListModel("CustomPainter","进度动画",CircelProgress()),
    ListModel("DraggableScrollableSheet & AnimatedCrossFade","拖动",DraggableScrollableSheetScreen()),
    ListModel("Draw_path","draw path",DrawPathScreen()),
    ListModel("Warp","流布局",WarpScreen()),
    ListModel("StreamBuilder","数据流",ScreamBuilderScreen()),
    ListModel("SliverAppbar","根据滑动显示顶部内容",SliverAppScreens()),
    ListModel("layoutBuilder","可根据屏幕宽度改变UI",LayoutBuilderScreen()),
    ListModel("Dismissable","滑动删除组件",DismissableScreen()),
    ListModel("AnimationIcon","动画图标组件",AnimationIconScreen()),
    ListModel("ReorderlistView","列表排序", ReorderlistViewScreen()),
    ListModel("Notifier", "跨组件通知",NotifierPage()),
    ListModel("Picker","选择器",PickerPage()),
    ListModel("CustomSlider","自定义控件",CustomSlider()),
    ListModel("flutter调用原生UI","", CustomNativePage()),
    ListModel("Stepper","步骤指示", StepperPage()),
    ListModel("ButtomSheet","从底部弹窗", BottomSheetPage()),
    ListModel("文件操作","从读取写入文件", FileOperations()),
  ];

  var light = true;

  @override
  Widget build(BuildContext context) {

    final theme = Provider.of<ThemeChanger>(context);

    return Scaffold(
      appBar: AppBar(
        title: Text("Main List"),
        leading: IconButton(
          icon: Icon(Icons.chat_bubble_outline),
          onPressed: () async {
            var res = await CallManager.call({"msg":"zoulin"});
            print("调用原生回调======"+res);
          },
        ),
        actions: <Widget>[
          Switch(
            value: light,
            activeColor: Colors.white,
            onChanged: (val){
              setState(() {
                light = val;
              });
              theme.switchTheme();
            },
          )
        ],
      ),
      body: Container(
        child: ListView.builder(
          itemCount: _datasource.length,
          itemBuilder: (context, index){
            ListModel model = _datasource[index];
            return Container(
                child: ListTile(
                  title: Text(model.title),
                  subtitle: Text(model.detail),
                  onTap: (){
                    Navigator.of(context).push(MaterialPageRoute(builder: (context) => model.jump));
                  },
                ),
              );
          },
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: (){
          Navigator.of(context).push(PageTransition(type: PageTransitionType.fade,child: NotifierPage()));
        },
      ),
    );
  }
}

